use std::fmt;

#[derive(Debug)]
struct Structure(i32);

#[derive(Debug)]
struct Deep(Structure);

struct Person<'a> {
    name: &'a str,
    age: u8,
}

impl<'a> fmt::Display for Person<'a>{
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        // 自定义格式，使得仅显示 `x` 和 `y` 的值。
        write!(f, "name: {}, age: {}", self.name, self.age)
    }
}


fn main() {
    println!("Hello, world!");
    let s = Structure(10);
    let d = Deep(s);

    println!("{:?}", d);
    println!("{:#?}", d);

    println!("{:?} months in a year.", 12);
    println!("{1:?} {0:?} is the {actor:?} name.",
             "Slater",
             "Christian",
             actor = "actor's");

    let name = "perter";
    let age = 27;
    let peter = Person { name, age };

    println!("{}", peter)
}
